#include "arithmetic.hpp"

struct	Symbol
{
	unsigned int	low;
	unsigned int	high;
};

void	*arithmetic_encode(unsigned int const size, unsigned char const *data, unsigned int &newsize)
{
	unsigned int	count[256];
	Symbol			symbols[256];
	
	unsigned int	low = 0;
	unsigned int	high = size;
	
	for (unsigned int i = 0; i < 256; ++i)
		count[i] = 0;
	for (unsigned int i = 0; i < size; ++i)
		++count[data[i]];
	double ratio = (double)0xffffffff / size;
	for (unsigned int i = 0; i < 256; ++i)
	{
		symbols[i].low = low;
		low = low + count[i] *
		symbols[i].high = low + (unsigned int)(count[i] * ratio);
	}
}

void	*arithmetic_decode(unsigned int const size, unsigned char const *data, unsigned int &newsize)
{

}
